<%--
  Created by IntelliJ IDEA.
  User: 范军建
  Date: 2022/3/29
  Time: 21:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>

<%
    request.setCharacterEncoding("utf-8");

    String userName = request.getParameter("userName");
    String password = request.getParameter("password");

    if (userName.equals("admin") && password.equals("123456")) {
        Cookie mycook=new Cookie("userInfo",userName+"#"+password);  //设置cookie对象
        mycook.setMaxAge(60*60*20*365); //设置cookie有效期
        response.addCookie(mycook);//把cookie对象发送到客户端进行存储
%>

<script>
    alert("登录成功!");
    window.location.href = "text1.jsp";
</script>

<%
} else {
%>
<script>
    alert("登录失败,用户名或者密码错误");
    window.location.href = "text1.jsp";
</script>

<%
    }
%>




</body>
</html>
